<!DOCTYPE html>
<html lang="zh_CN">
<head>
    <#include "../common/header.ftl"/>
<script>
    $(function () {
        $(".changeBtn").click(function () {
            $("#inputModal").clearForm(true)
            var json=$(this).data("json")
            console.log(json);
            if (json){
                $("#editForm input[name='id']").val(json.id)
                $("#editForm input[name='travel.id']").val(json.travelId)
                $("#editForm input[name='title']").val(json.title)
                $("#editForm input[name='subTitle']").val(json.subTitle)
                $("#coverUrl").prop("src",json.coverUrl)
                $("#editForm input[name='coverUrl']").val(json.coverUrl)
                $("#editForm input[name='schedule']").val(json.schedule)
                $("#editForm select[name='type']").val(json.type)
                $("#skip").prop("href",$("#skip").data("href")+json.travelId)
            }
            $("#inputModal").modal('show')
        })

        $("#saveBtn").click(function () {
            $("#editForm").ajaxSubmit(function (data) {
                if (data.success) {
                    window.location.reload()
                }
            })
        })
        //跳转到指定文章

    })
    
</script>
</head>
<body>

<div class="container " style="margin-top: 20px">
    <#include "../common/top.ftl"/>
    <div class="row">
        <div class="col-sm-3">
        <#--设置当前要回显当前菜单,必须在载人菜单前完成设置-->
            <#assign menu="travelCommend"/>
            <#include "../common/menu.ftl"/>
        </div>
        <div class="col-sm-9">
            <div class="row">
                <div class="col-sm-12">
                    <h1 class="page-head-line">游记推荐管理</h1>
                </div>
            </div>
            <!--高级查询--->
            <form class="form-inline" id="searchForm" action="" method="post">
                <input type="hidden" id="currentPage" name="currentPage" value="1">
                <div class="form-group">
                    <label>关键字:</label>
                    <input type="text" class="form-control" name="keyword" value="${(qo.keyword)!}"
                           placeholder="请输入标题">
                </div>
                <div class="form-group">
                    <select  class="form-control" name="type" id="typeS"">
                        <option value="-1">全部</option>
                        <option value="1">周推荐</option>
                        <option value="2">月推荐</option>
                        <option value="3">攻略推荐</option>
                    </select>
                    <script>
                        $("#typeS").val(${(qo.type)!})
                    </script>
                </div>
                <button id="btn_query" class="btn btn-info">
                    <span class="glyphicon glyphicon-search"></span> 查询
                </button>
            </form>

            <table class="table table-striped table-hover">
                <tr>
                    <th>封面</th>
                    <th>标题</th>
                    <th>副标题</th>
                    <th>推荐时间安排</th>
                    <th>推荐类型</th>
                    <th></th>
                </tr>
                <#list pageInfo.list as entity>
                    <tr>
                        <td><img src="${entity.coverUrl!}" width="30px"></td>
                        <td>${entity.title!}</td>
                        <td>${(entity.subTitle)!}</td>
                        <td>${(entity.schedule?string("yyyy-MM-dd"))!}</td>
                        <td>${entity.typeName!}</td>
                        <td>
                            <a href="javaScript:;" class="changeBtn" data-json='${entity.jsonString!}'>修改</a>
                        </td>
                    </tr>
                </#list>
            </table>
           <#include "../common/page.ftl"/>
        </div>
    </div>
</div>
<#--模态框-->
<div id="inputModal" class="modal" tabindex="-1" role="dialog">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">编辑/增加</h4>
            </div>
            <div class="modal-body">
                <form id="editForm" class="form-horizontal" method="post" action="/travelCommend/save.do" enctype="multipart/form-data" style="margin: -3px 118px">
                    <input id="travelCommendId" type="hidden" name="id" value="" />
                    <input id="travelId" type="hidden" name="travel.id" value="" />
                    <div class="form-group">
                        <label class="col-sm-4 control-label">标题</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" id="title" name="title" placeholder="标题">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-4 control-label">副标题</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" id="subTitle" name="subTitle" placeholder="副标题">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-4 control-label">封面</label>
                        <div class="col-sm-6">
                            <img id="coverUrl" width="200px"/>
                            <input type="hidden" name="coverUrl" id="cover">
                            <input type="file" class="form-control" id="pic" name="pic" >
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-4 control-label">推荐时间</label>
                        <div class="col-sm-6">
                            <input type="text" id="schedule" name="schedule" class="form-control" onclick="WdatePicker()">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-4 control-label">推荐类型</label>
                        <div class="col-sm-6">
                            <select id="type" class="form-control"  autocomplete="off" name="type" >
                                <option value="1">每月推荐</option>
                                <option value="2">每周推荐</option>
                                <option value="3">攻略推荐</option>
                            </select>
                        </div>
                    </div>
                    <div class="form-group" style="text-align: center">
                        <a data-href="/travel/passList.do?travelId=" target="_blank" id="skip" >点击查看游记文章明细</a>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <a href="javascript:void(0);" class="btn btn-success" id="saveBtn" aria-hidden="true">保存</a>
                <a href="javascript:void(0);" class="btn" data-dismiss="modal" aria-hidden="true">关闭</a>
            </div>
        </div>
    </div>
</div>


</body>
</html>